package com.settings;

import java.util.ArrayList;

import com.google.android.maps.GeoPoint;
import com.route.DetailedLocation;

public class SettingsAdapter {
	public static boolean saveSettings(){
		String strBuilder = "";
		if(SettingsParameters.loginValidated){
		    strBuilder += "username;"+SettingsParameters.username + "\n";
		    strBuilder += "password;"+SettingsParameters.password + "\n";
		}
		SettingsProvider.writeFile(strBuilder);
		return true;
	}
	public static void retriveSettings(){
		try{
			//ArrayList<DetailedLocation> locationList = new ArrayList<DetailedLocation>();
			String rawString = SettingsProvider.readFile();
			String [] rawSettings = rawString.split("\n");
			for(String rawSetting:rawSettings){
				String [] rawSettingsLine = rawSetting.split(";");
				try{
					if(rawSettingsLine[0].equals("username")){
					    SettingsParameters.username = rawSettingsLine[1];
					}
					if(rawSettingsLine[0].equals("password")){
					    SettingsParameters.password = rawSettingsLine[1];
					    SettingsParameters.loginValidated = true;
					}
				}catch(Exception e){
				}
			}
			//return locationList;
		}catch(Exception e){
			//return null;
		}


	}
}
